package com.shop.seller.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.mchange.v2.beans.BeansUtils;
import com.shop.domain.CustomItemCat;
import com.shop.mapper.ItemCatMapper;
import com.shop.model.ItemCat;
import com.shop.model.ItemCatExample;
import com.shop.model.ItemCatExample.Criteria;
import com.shop.seller.service.ItemCatService;
@Service("itemCatService")
public class ItemCatServiceBean implements ItemCatService{

	@Resource
	private ItemCatMapper itemCatMapper;
	@Override
	public String findItemCatByParentId(Long parentid) throws Exception {
		ItemCatExample example=new ItemCatExample();
		Criteria criteria=example.createCriteria();
		criteria.andParentIdEqualTo(parentid);
		List<ItemCat> itemCats=itemCatMapper.selectByExample(example);
		String json=JSON.toJSON(itemCats).toString();

		return json;
	}
	@Override
	public ItemCat findItemCatById(Long id) throws Exception {
		ItemCat itemCat=itemCatMapper.selectByPrimaryKey(id);
		return itemCat;
	}

}
